var $ = jQuery;

$(document).ready(function ($) {

  var duration = Drupal.settings.scmedia_popup_ad.settings.scmedia_popup_ad_display_time;
  var count = parseInt(duration) / 1000;

  $('body.front .popup-overlay').show();

  $('body.front .popup-close-button').click(function() {
      $('body.front .popup-overlay').hide();
  });

  //Advertise display duration
  var timer = setInterval(function() {
    if (count >= 0) {
      $('body.front .popup-timeout').text('Close in '+ count);
    }
	else {
	  $('body.front .popup-overlay').fadeOut(300);
      clearInterval(timer);
    }
    count--;
  }, 1000);

 // $('body #custom_splash').delay(parseInt(duration)).fadeOut(300);
});
